﻿'
' DKP for DotNetNuke® - http://dkpdnn.codeplex.com
' Copyright (c) 2008
' by Casey Lengacher ( http://dkpdnn.codeplex.com )
'
' DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation.
'
' Permission is hereby granted, free of charge, to any person obtaining a copy
' of this software and associated documentation files (the "Software"), to deal
' in the Software without restriction, including without limitation the rights
' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
' copies of the Software, and to permit persons to whom the Software is
' furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in
' all copies or substantial portions of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
' SOFTWARE.
'

Imports DotNetNuke.Common.Utilities

Namespace DotNetNuke.Modules.tss_DKP

    Partial Public Class tss_ucPlayerDetails

        Inherits Entities.Modules.PortalModuleBase

#Region "Private Variables"

        Private Enum PageState As Integer
            NotSet = -1
            View = 0
            Add = 1
            SingleUpdate = 2
            MultiUpdate = 3
        End Enum

#End Region

#Region "Private Properties"

        Private Property vsLootsPageSize() As Integer
            Get
                If ViewState("tss_PlayerDetailLootsPageSize") Is Nothing Then
                    If (Request.Cookies.Get("tss_PlayerDetailLootsPageSize") Is Nothing) Then
                        Return ddlLootsPageSize.Items(0).Value
                    Else
                        Return CInt(Request.Cookies.Get("tss_PlayerDetailLootsPageSize").Value)
                    End If
                Else
                    Return CInt(ViewState("tss_PlayerDetailLootsPageSize"))
                End If
            End Get
            Set(ByVal Value As Integer)
                ViewState("tss_PlayerDetailLootsPageSize") = Value
                Response.Cookies("tss_PlayerDetailLootsPageSize").Expires = DateTime.Now.AddYears(10)
                Response.Cookies("tss_PlayerDetailLootsPageSize").Value = Value
            End Set
        End Property

        Private Property vsLootsSortExpression() As String
            Get
                If ViewState("tss_PlayerDetailLootsSortExpression") Is Nothing Then
                    If (Request.Cookies.Get("tss_PlayerDetailLootsSortExpression") Is Nothing) Then
                        Return "RaidDate"
                    Else
                        Return CStr(Request.Cookies.Get("tss_PlayerDetailLootsSortExpression").Value)
                    End If
                Else
                    Return CStr(ViewState("tss_PlayerDetailLootsSortExpression"))
                End If
            End Get
            Set(ByVal Value As String)
                ViewState("tss_PlayerDetailLootsSortExpression") = Value
                Response.Cookies("tss_PlayerDetailLootsSortExpression").Expires = DateTime.Now.AddYears(10)
                Response.Cookies("tss_PlayerDetailLootsSortExpression").Value = Value
            End Set
        End Property

        Private Property vsLootsSortDirection() As String
            Get
                If ViewState("tss_PlayerDetailLootsSortDirection") Is Nothing Then
                    If (Request.Cookies.Get("tss_PlayerDetailLootsSortDirection") Is Nothing) Then
                        Return "DESC"
                    Else
                        Return CStr(Request.Cookies.Get("tss_PlayerDetailLootsSortDirection").Value)
                    End If
                Else
                    Return CStr(ViewState("tss_PlayerDetailLootsSortDirection"))
                End If
            End Get
            Set(ByVal Value As String)
                ViewState("tss_PlayerDetailLootsSortDirection") = Value
                Response.Cookies("tss_PlayerDetailLootsSortDirection").Expires = DateTime.Now.AddYears(10)
                Response.Cookies("tss_PlayerDetailLootsSortDirection").Value = Value
            End Set
        End Property

        Private Property vsLootsCurrentPage() As Integer
            Get
                If ViewState("tss_PlayerDetailLootsCurrentPage") Is Nothing Then
                    Return 1
                Else
                    Return CInt(ViewState("tss_PlayerDetailLootsCurrentPage"))
                End If
            End Get
            Set(ByVal Value As Integer)
                ViewState("tss_PlayerDetailLootsCurrentPage") = Value
            End Set
        End Property

        Private Property vsLootsTotalPages() As Integer
            Get
                If ViewState("tss_PlayerDetailLootsTotalPages") Is Nothing Then
                    Return 1
                Else
                    Return CInt(ViewState("tss_PlayerDetailLootsTotalPages"))
                End If
            End Get
            Set(ByVal Value As Integer)
                ViewState("tss_PlayerDetailLootsTotalPages") = Value
            End Set
        End Property

        Private Property vsRaidsPageSize() As Integer
            Get
                If ViewState("tss_PlayerDetailRaidsPageSize") Is Nothing Then
                    If (Request.Cookies.Get("tss_PlayerDetailRaidsPageSize") Is Nothing) Then
                        Return ddlRaidsPageSize.Items(0).Value
                    Else
                        Return CInt(Request.Cookies.Get("tss_PlayerDetailRaidsPageSize").Value)
                    End If
                Else
                    Return CInt(ViewState("tss_PlayerDetailRaidsPageSize"))
                End If
            End Get
            Set(ByVal Value As Integer)
                ViewState("tss_PlayerDetailRaidsPageSize") = Value
                Response.Cookies("tss_PlayerDetailRaidsPageSize").Expires = DateTime.Now.AddYears(10)
                Response.Cookies("tss_PlayerDetailRaidsPageSize").Value = Value
            End Set
        End Property

        Private Property vsRaidsSortExpression() As String
            Get
                If ViewState("tss_PlayerDetailRaidsSortExpression") Is Nothing Then
                    If (Request.Cookies.Get("tss_PlayerDetailRaidsSortExpression") Is Nothing) Then
                        Return "RaidDate"
                    Else
                        Return CStr(Request.Cookies.Get("tss_PlayerDetailRaidsSortExpression").Value)
                    End If
                Else
                    Return CStr(ViewState("tss_PlayerDetailRaidsSortExpression"))
                End If
            End Get
            Set(ByVal Value As String)
                ViewState("tss_PlayerDetailRaidsSortExpression") = Value
                Response.Cookies("tss_PlayerDetailRaidsSortExpression").Expires = DateTime.Now.AddYears(10)
                Response.Cookies("tss_PlayerDetailRaidsSortExpression").Value = Value
            End Set
        End Property

        Private Property vsRaidsSortDirection() As String
            Get
                If ViewState("tss_PlayerDetailRaidsSortDirection") Is Nothing Then
                    If (Request.Cookies.Get("tss_PlayerDetailRaidsSortDirection") Is Nothing) Then
                        Return "DESC"
                    Else
                        Return CStr(Request.Cookies.Get("tss_PlayerDetailRaidsSortDirection").Value)
                    End If
                Else
                    Return CStr(ViewState("tss_PlayerDetailRaidsSortDirection"))
                End If
            End Get
            Set(ByVal Value As String)
                ViewState("tss_PlayerDetailRaidsSortDirection") = Value
                Response.Cookies("tss_PlayerDetailRaidsSortDirection").Expires = DateTime.Now.AddYears(10)
                Response.Cookies("tss_PlayerDetailRaidsSortDirection").Value = Value
            End Set
        End Property

        Private Property vsRaidsCurrentPage() As Integer
            Get
                If ViewState("tss_PlayerDetailRaidsCurrentPage") Is Nothing Then
                    Return 1
                Else
                    Return CInt(ViewState("tss_PlayerDetailRaidsCurrentPage"))
                End If
            End Get
            Set(ByVal Value As Integer)
                ViewState("tss_PlayerDetailRaidsCurrentPage") = Value
            End Set
        End Property

        Private Property vsRaidsTotalPages() As Integer
            Get
                If ViewState("tss_PlayerDetailRaidsTotalPages") Is Nothing Then
                    Return 1
                Else
                    Return CInt(ViewState("tss_PlayerDetailRaidsTotalPages"))
                End If
            End Get
            Set(ByVal Value As Integer)
                ViewState("tss_PlayerDetailRaidsTotalPages") = Value
            End Set
        End Property

        Private Property vsPlayerID() As Integer
            Get
                If ViewState("tss_PlayerID") Is Nothing Then
                    Return Null.NullInteger
                Else
                    Return CInt(ViewState("tss_PlayerID"))
                End If
            End Get
            Set(ByVal Value As Integer)
                ViewState("tss_PlayerID") = Value
            End Set
        End Property

#End Region

#Region "Private Methods"

        Private Sub BindPage()

            Dim tss_DKP As New tss_DataController
            Dim intLootsRowsAffected, intRaidsRowsAffected As Integer
            Dim intLootsPageNumber As Integer = vsLootsCurrentPage
            Dim intRaidsPageNumber As Integer = vsRaidsCurrentPage
            Dim intPlayerID As Integer = vsPlayerID
            Dim dblLootsPagesAffected As Double = 1
            Dim dblRaidsPagesAffected As Double = 1

            ddlLootsPageSize.SelectedValue = ddlLootsPageSize.Items.FindByText(vsLootsPageSize).Value
            ddlRaidsPageSize.SelectedValue = ddlRaidsPageSize.Items.FindByText(vsRaidsPageSize).Value

            grdLoots.PageSize = vsLootsPageSize
            grdRaids.PageSize = vsRaidsPageSize

            For Each currentColumn As DataGridColumn In grdLoots.Columns
                currentColumn.HeaderText = currentColumn.HeaderText.Substring(0, _
                    IIf(currentColumn.HeaderText.IndexOf(" <img") > 0, currentColumn.HeaderText.IndexOf(" <img"), currentColumn.HeaderText.Length))
                If (currentColumn.SortExpression = vsLootsSortExpression) Then
                    If (vsLootsSortDirection = "ASC") Then
                        currentColumn.HeaderText = currentColumn.HeaderText _
                            + " <img src='/DesktopModules/tss_DKP/Images/grid_icon_uparrow.png' border=0 height=10 width=10>"
                    Else
                        currentColumn.HeaderText = currentColumn.HeaderText _
                            + " <img src='/DesktopModules/tss_DKP/Images/grid_icon_downarrow.png' border=0 height=10 width=10>"
                    End If
                End If
            Next

            For Each currentColumn As DataGridColumn In grdRaids.Columns
                currentColumn.HeaderText = currentColumn.HeaderText.Substring(0, _
                    IIf(currentColumn.HeaderText.IndexOf(" <img") > 0, currentColumn.HeaderText.IndexOf(" <img"), currentColumn.HeaderText.Length))
                If (currentColumn.SortExpression = vsRaidsSortExpression) Then
                    If (vsRaidsSortDirection = "ASC") Then
                        currentColumn.HeaderText = currentColumn.HeaderText _
                            + " <img src='/DesktopModules/tss_DKP/Images/grid_icon_uparrow.png' border=0 height=10 width=10>"
                    Else
                        currentColumn.HeaderText = currentColumn.HeaderText _
                            + " <img src='/DesktopModules/tss_DKP/Images/grid_icon_downarrow.png' border=0 height=10 width=10>"
                    End If
                End If
            Next

            grdLoots.DataSource = tss_DKP.tss_GetLootsForPlayerByPage(intPlayerID, intLootsPageNumber, grdLoots.PageSize, vsLootsSortExpression, vsLootsSortDirection, intLootsRowsAffected)
            grdLoots.DataBind()

            grdRaids.DataSource = tss_DKP.tss_GetRaidsForPlayerByPage(intPlayerID, intRaidsPageNumber, grdRaids.PageSize, vsRaidsSortExpression, vsRaidsSortDirection, intRaidsRowsAffected)
            grdRaids.DataBind()

            If (grdLoots.Items.Count = 0) And (intLootsPageNumber > 1) Then
                intLootsPageNumber = intLootsPageNumber - 1
                vsLootsCurrentPage = intLootsPageNumber.ToString()
                grdLoots.DataSource = tss_DKP.tss_GetLootsForPlayerByPage(intPlayerID, intLootsPageNumber, grdLoots.PageSize, vsLootsSortExpression, vsLootsSortDirection, intLootsRowsAffected)
                grdLoots.DataBind()
            End If

            If (grdRaids.Items.Count = 0) And (intRaidsPageNumber > 1) Then
                intRaidsPageNumber = intRaidsPageNumber - 1
                vsRaidsCurrentPage = intRaidsPageNumber.ToString()
                grdRaids.DataSource = tss_DKP.tss_GetRaidsForPlayerByPage(intPlayerID, intRaidsPageNumber, grdRaids.PageSize, vsRaidsSortExpression, vsRaidsSortDirection, intRaidsRowsAffected)
                grdRaids.DataBind()
            End If

            dblLootsPagesAffected = System.Math.Ceiling(intLootsRowsAffected / grdLoots.PageSize)
            If (dblLootsPagesAffected < 1) Then
                dblLootsPagesAffected = 1
            End If
            vsLootsTotalPages = dblLootsPagesAffected.ToString()
            lblLootsCurrentPage.Text = vsLootsCurrentPage
            lblLootsTotalPages.Text = vsLootsTotalPages

            dblRaidsPagesAffected = System.Math.Ceiling(intRaidsRowsAffected / grdRaids.PageSize)
            If (dblRaidsPagesAffected < 1) Then
                dblRaidsPagesAffected = 1
            End If
            vsRaidsTotalPages = dblRaidsPagesAffected.ToString()
            lblRaidsCurrentPage.Text = vsRaidsCurrentPage
            lblRaidsTotalPages.Text = vsRaidsTotalPages

            If (intLootsPageNumber = 1) Then
                lnkLootsPreviousPage.Enabled = False

                If (dblLootsPagesAffected > 1) Then
                    lnkLootsNextPage.Enabled = True
                    lnkLootsLastPage.Enabled = True
                Else
                    lnkLootsNextPage.Enabled = False
                    lnkLootsLastPage.Enabled = False
                End If
            Else
                lnkLootsPreviousPage.Enabled = True

                If (intLootsPageNumber = dblLootsPagesAffected) Then
                    lnkLootsNextPage.Enabled = False
                    lnkLootsLastPage.Enabled = False
                Else
                    lnkLootsNextPage.Enabled = True
                    lnkLootsLastPage.Enabled = True
                End If
            End If

            If (intRaidsPageNumber = 1) Then
                lnkRaidsPreviousPage.Enabled = False

                If (dblRaidsPagesAffected > 1) Then
                    lnkRaidsNextPage.Enabled = True
                    lnkRaidsLastPage.Enabled = True
                Else
                    lnkRaidsNextPage.Enabled = False
                    lnkRaidsLastPage.Enabled = False
                End If
            Else
                lnkRaidsPreviousPage.Enabled = True

                If (intRaidsPageNumber = dblRaidsPagesAffected) Then
                    lnkRaidsNextPage.Enabled = False
                    lnkRaidsLastPage.Enabled = False
                Else
                    lnkRaidsNextPage.Enabled = True
                    lnkRaidsLastPage.Enabled = True
                End If
            End If

        End Sub

        Private Sub ManagePageState(ByVal PageState As PageState)

            BindPage()

        End Sub

#End Region

#Region "Private Event Handlers"

        Private Sub ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles grdLoots.ItemDataBound, grdRaids.ItemDataBound

            If (sender.Equals(grdLoots)) Then

                If (e.Item.ItemType.Equals(ListItemType.Item)) Or (e.Item.ItemType.Equals(ListItemType.AlternatingItem)) Then

                    Dim lblRaidDate As Label = e.Item.FindControl("lblRaidDate")
                    Dim lnkItemWowHeadID As HyperLink = e.Item.FindControl("lnkItemWowHeadID")
                    Dim lblItemName As Label = e.Item.FindControl("lblItemName")
                    Dim lblLootValue As Label = e.Item.FindControl("lblLootValue")

                    Dim objLoot As tss_LootInfo = e.Item.DataItem

                    lblRaidDate.Text = objLoot.RaidDate.ToString("MM/dd/yy hh:mm tt")

                    If (objLoot.ItemWowHeadID.Length = 0) Then
                        lnkItemWowHeadID.ImageUrl = "/DesktopModules/tss_DKP/Images/grid_icon_blank.png"
                        lnkItemWowHeadID.Enabled = False
                    Else
                        lnkItemWowHeadID.ImageUrl = "/DesktopModules/tss_DKP/Images/grid_icon_wowhead.png"
                        lnkItemWowHeadID.NavigateUrl = "http://www.wowhead.com/?item=" + objLoot.ItemWowHeadID
                        lnkItemWowHeadID.Target = "_new"
                        lnkItemWowHeadID.Enabled = True
                        lnkItemWowHeadID.ToolTip = "View WowHead"
                    End If

                    lblItemName.Text = objLoot.ItemName
                    lblLootValue.Text = objLoot.LootValue

                End If

            ElseIf (sender.Equals(grdRaids)) Then

                If (e.Item.ItemType.Equals(ListItemType.Item)) Or (e.Item.ItemType.Equals(ListItemType.AlternatingItem)) Then

                    Dim lblRaidDate As Label = e.Item.FindControl("lblRaidDate")
                    Dim lnkMobWowHeadID As HyperLink = e.Item.FindControl("lnkMobWowHeadID")
                    Dim lblMobName As Label = e.Item.FindControl("lblMobName")
                    Dim lblRaidValue As Label = e.Item.FindControl("lblRaidValue")

                    Dim objRaid As tss_RaidInfo = e.Item.DataItem

                    lblRaidDate.Text = objRaid.RaidDate.ToString("MM/dd/yy hh:mm tt")

                    If (objRaid.MobWowHeadID.Length = 0) Then
                        lnkMobWowHeadID.ImageUrl = "/DesktopModules/tss_DKP/Images/grid_icon_blank.png"
                        lnkMobWowHeadID.Enabled = False
                    Else
                        lnkMobWowHeadID.ImageUrl = "/DesktopModules/tss_DKP/Images/grid_icon_wowhead.png"
                        lnkMobWowHeadID.NavigateUrl = "http://www.wowhead.com/?npc=" + objRaid.MobWowHeadID
                        lnkMobWowHeadID.Target = "_new"
                        lnkMobWowHeadID.Enabled = True
                        lnkMobWowHeadID.ToolTip = "View WowHead"
                    End If

                    lblMobName.Text = objRaid.MobName
                    lblRaidValue.Text = objRaid.RaidValue

                End If

            End If

        End Sub

        Private Sub ItemCreated(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles grdLoots.ItemCreated, grdRaids.ItemCreated

            If (sender.Equals(grdLoots)) Then

                If (e.Item.ItemType.Equals(ListItemType.Header)) Then

                    For Each currentCell As TableCell In e.Item.Cells
                        currentCell.Attributes.Add("class", "dkpdnn_GridHeader" + grdLoots.Columns(e.Item.Cells.GetCellIndex(currentCell)).FooterText)
                    Next

                ElseIf (e.Item.ItemType.Equals(ListItemType.Item)) Then

                    e.Item.Attributes.Add("class", "dkpdnn_GridItem")
                    e.Item.Attributes.Add("onmouseover", "className='dkpdnn_GridItemMouseOver';")
                    e.Item.Attributes.Add("onmouseout", "className='dkpdnn_GridItem';")

                    For Each currentCell As TableCell In e.Item.Cells
                        currentCell.Attributes.Add("class", "dkpdnn_GridItem" + grdLoots.Columns(e.Item.Cells.GetCellIndex(currentCell)).FooterText)
                    Next

                ElseIf (e.Item.ItemType.Equals(ListItemType.AlternatingItem)) Then

                    e.Item.Attributes.Add("class", "dkpdnn_GridAltItem")
                    e.Item.Attributes.Add("onmouseover", "className='dkpdnn_GridAltItemMouseOver';")
                    e.Item.Attributes.Add("onmouseout", "className='dkpdnn_GridAltItem';")

                    For Each currentCell As TableCell In e.Item.Cells
                        currentCell.Attributes.Add("class", "dkpdnn_GridAltItem" + grdLoots.Columns(e.Item.Cells.GetCellIndex(currentCell)).FooterText)
                    Next

                ElseIf (e.Item.ItemType.Equals(ListItemType.Footer)) Then

                    e.Item.Visible = False

                End If

            ElseIf (sender.Equals(grdRaids)) Then

                If (e.Item.ItemType.Equals(ListItemType.Header)) Then

                    For Each currentCell As TableCell In e.Item.Cells
                        currentCell.Attributes.Add("class", "dkpdnn_GridHeader" + grdRaids.Columns(e.Item.Cells.GetCellIndex(currentCell)).FooterText)
                    Next

                ElseIf (e.Item.ItemType.Equals(ListItemType.Item)) Then

                    e.Item.Attributes.Add("class", "dkpdnn_GridItem")
                    e.Item.Attributes.Add("onmouseover", "className='dkpdnn_GridItemMouseOver';")
                    e.Item.Attributes.Add("onmouseout", "className='dkpdnn_GridItem';")

                    For Each currentCell As TableCell In e.Item.Cells
                        currentCell.Attributes.Add("class", "dkpdnn_GridItem" + grdRaids.Columns(e.Item.Cells.GetCellIndex(currentCell)).FooterText)
                    Next

                ElseIf (e.Item.ItemType.Equals(ListItemType.AlternatingItem)) Then

                    e.Item.Attributes.Add("class", "dkpdnn_GridAltItem")
                    e.Item.Attributes.Add("onmouseover", "className='dkpdnn_GridAltItemMouseOver';")
                    e.Item.Attributes.Add("onmouseout", "className='dkpdnn_GridAltItem';")

                    For Each currentCell As TableCell In e.Item.Cells
                        currentCell.Attributes.Add("class", "dkpdnn_GridAltItem" + grdRaids.Columns(e.Item.Cells.GetCellIndex(currentCell)).FooterText)
                    Next

                ElseIf (e.Item.ItemType.Equals(ListItemType.Footer)) Then

                    e.Item.Visible = False

                End If

            End If

        End Sub

        Private Sub SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ddlLootsPageSize.SelectedIndexChanged, ddlRaidsPageSize.SelectedIndexChanged

            If (sender.Equals(ddlLootsPageSize)) Then

                vsLootsPageSize = ddlLootsPageSize.SelectedValue
                ManagePageState(PageState.View)

            ElseIf (sender.Equals(ddlRaidsPageSize)) Then

                vsRaidsPageSize = ddlRaidsPageSize.SelectedValue
                ManagePageState(PageState.View)

            End If

        End Sub

        Private Sub SortCommand(ByVal sender As Object, ByVal e As DataGridSortCommandEventArgs) Handles grdLoots.SortCommand, grdRaids.SortCommand

            If (sender.Equals(grdLoots)) Then

                If (vsLootsSortExpression = e.SortExpression) Then
                    If (vsLootsSortDirection = "ASC") Then
                        vsLootsSortDirection = "DESC"
                    ElseIf (vsLootsSortDirection = "DESC") Then
                        vsLootsSortDirection = "ASC"
                    End If
                Else
                    vsLootsSortExpression = e.SortExpression
                    vsLootsSortDirection = "ASC"
                End If

            ElseIf (sender.Equals(grdRaids)) Then

                If (vsRaidsSortExpression = e.SortExpression) Then
                    If (vsRaidsSortDirection = "ASC") Then
                        vsRaidsSortDirection = "DESC"
                    ElseIf (vsRaidsSortDirection = "DESC") Then
                        vsRaidsSortDirection = "ASC"
                    End If
                Else
                    vsRaidsSortExpression = e.SortExpression
                    vsRaidsSortDirection = "ASC"
                End If

            End If

            ManagePageState(PageState.View)

        End Sub

        Private Sub Click(ByVal sender As Object, ByVal e As EventArgs) Handles lnkLootsFirstPage.Click, lnkLootsPreviousPage.Click, _
            lnkLootsNextPage.Click, lnkLootsLastPage.Click, lnkRaidsFirstPage.Click, lnkRaidsPreviousPage.Click, lnkRaidsNextPage.Click, _
            lnkRaidsLastPage.Click, lnkReturnToPlayers.Click

            Dim tss_DKP_Parent As tss_DKP = Me.Parent.Parent

            If (sender.Equals(lnkLootsFirstPage)) Then

                vsLootsCurrentPage = 1
                ManagePageState(PageState.View)

            ElseIf (sender.Equals(lnkLootsPreviousPage)) Then

                vsLootsCurrentPage = CInt(vsLootsCurrentPage) - 1
                ManagePageState(PageState.View)

            ElseIf (sender.Equals(lnkLootsNextPage)) Then

                vsLootsCurrentPage = CInt(vsLootsCurrentPage) + 1
                ManagePageState(PageState.View)

            ElseIf (sender.Equals(lnkLootsLastPage)) Then

                vsLootsCurrentPage = vsLootsTotalPages
                ManagePageState(PageState.View)

            ElseIf (sender.Equals(lnkRaidsFirstPage)) Then

                vsRaidsCurrentPage = 1
                ManagePageState(PageState.View)

            ElseIf (sender.Equals(lnkRaidsPreviousPage)) Then

                vsRaidsCurrentPage = CInt(vsRaidsCurrentPage) - 1
                ManagePageState(PageState.View)

            ElseIf (sender.Equals(lnkRaidsNextPage)) Then

                vsRaidsCurrentPage = CInt(vsRaidsCurrentPage) + 1
                ManagePageState(PageState.View)

            ElseIf (sender.Equals(lnkRaidsLastPage)) Then

                vsRaidsCurrentPage = vsRaidsTotalPages
                ManagePageState(PageState.View)

            ElseIf (sender.Equals(lnkReturnToPlayers)) Then

                tss_DKP_Parent.lnkReturnToPlayers_Click()

            End If

        End Sub

#End Region

#Region "Public Methods"

        Public Sub Initialize(ByVal objPlayer As tss_PlayerInfo)

            vsPlayerID = objPlayer.PlayerID
            ManagePageState(PageState.View)

        End Sub

#End Region

    End Class

End Namespace
